home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Cream of the Crop 20
/
Cream of the Crop 20 (Terry Blount) (1996).iso
/
program
/
n_b_v203.zip
/
ARRSUM_B.DMO
< prev
next >
Wrap
Text File
|
1996-07-04
|
5KB
|
74 lines
$if 0
┌──────────────────────────╖ PowerBASIC v3.20
┌──┤ DASoft ╟──────────────────────┬──────────────────╖
│ ├──────────────────────────╢ Copyright 1995 │ DATE: 1995-10-01 ╟─╖
│ │ FILE NAME ARRSUM_B.DMO ║ by ╘════════════════─ ║ ║
│ │ ║ Don Schullian, Jr. ║ ║
│ ╘══════════════════════════╝ ║ ║
│ A license is hereby granted to the holder to use this source code in ║ ║
│ any program, commercial or otherwise, without receiving the express ║ ║
│ permission of the copyright holder and without paying any royalties, ║ ║
│ as long as this code is not distributed in any compilable format. ║ ║
│ IE: source code files, PowerBASIC Unit files, and printed listings ║ ║
╘═╤═════════════════════════════════════════════════════════════════════╝ ║
│ .................................... ║
╘═══════════════════════════════════════════════════════════════════════╝
$endif
'.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°.°
' ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° ° °
$INCLUDE "DAS-NB01.INC"
RANDOMIZE TIMER
COLOR 7, 0
CLS
? "┌──────────────────────────────────────────────────────────────────────────────
? "│ fArrSumB?? ( ANYnumber, Els2Count%, StopAtSum??, ElsCounted%, StepSize% )
? "├──────────────────────────────────────────────────────────────────────────────
? "│ fArrSumB can count the elements of an array or a type. There are some natural
? "│ restrictions to the total and number of elements counted, etc. but they are
? "│ sufficiently high to allow for it's use under most circumstances. If you
? "│ assign a value of ZERO to StopAtSum?? fArrSumB will total all the elements,
? "│ but if it's value is > ZERO then fArrSumB will stop counting at the element
? "│ that offers a total =< StopAtSum?? and will return the number of elements
? "│ counted in ElsCounted%. StepSize% controls the number of bytes `skipped`
? "│ between the counted elements. ie: a one dimension byte array requires a
? "│ step size of +/- 1 (1 byte) where a TYPE could be almost any number.
? "└──────────────────────────────────────────────────────────────────────────────
'┌────────────────────
TYPE StockItemsTYPE '│ a type of 37 bytes
StockNo AS STRING * 14 '│ per element
ItemName AS STRING * 20 '│
BinNo AS INTEGER '│
InStock AS BYTE '│
END TYPE '│
'│
DIM tS(50) AS StockItemsTYPE '│ 50 working types
'│
FOR I% = 1 TO 50 '│ assign random vals
LSET tS(I%) = STRING$( 37, 0 ) '│ to the .InStock
tS(I%).InStock = fRND%( 1, 20 ) '│ count
NEXT '│
'│
I% = 50 '│ start at the end
F?? = 80 '│ max # of items/bin
S% = -37 '│ stepsize (backwards)
B% = 1 '│ 1st bin number
DO '│
T?? = fArrSumB??( tS(I%).InStock, I%, F??, C%, S% ) '│ T?? = actual total
PRINT USING "BIN_### HAS ## PIECES of";B%,T??; '│
PRINT USING " STOCK ITEM_#s ## thru ##";(I%-C%+1),I% '│ C% = items counted
DECR I%, C% '│
INCR B% '│
LOOP UNTIL I% = 0 '│
'│
PRINT '│ to get the ASCii
S$ = "HELLO WORLD" '│ values of a string
DIM S_ptr AS STRING PTR '│ try this trick.
S_ptr = STRPTR32( S$ ) '│
A?? = fArrSumB??( BYVAL S_ptr, LEN(S$), 0, Rels%, 1 ) '│ works pretty good
PRINT "THE ASCII VALUE OF THE 'HELLO WORLD' IS:"; A?? '│ too!
'└────────────────────